package com.lagou.flashsale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;

@SpringBootApplication
public class FlashsalePortalApplication {

    @Autowired
    private RedisTemplate<String, Integer> template;

    public static void main(String[] args) {
        SpringApplication.run(FlashsalePortalApplication.class, args);
    }

    // 启动时执行任务CommandLineRunner
    @Bean
    public CommandLineRunner runner() {
        // 初始化100条
        return args -> {
            template.opsForValue().set("goods_count", 100);
        };
    }

}
